package edu.stanford.jgc;

import edu.stanford.jgc.GeocoderWrapper.GeocoderWrapper;
import edu.stanford.jgc.datacollector.DataCollector;
import android.app.Activity;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class TestActivity extends Activity {
	/** Called when the activity is first created. */
	EditText address;
	Button submit;
	GeocoderWrapper coder;
	DataCollector dc;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        coder = new GeocoderWrapper(new Geocoder(this));
        dc = new DataCollector(coder);
        
        setContentView(R.layout.test);
        address = (EditText) findViewById(R.id.address);
        submit = (Button) findViewById(R.id.submit);
        submit.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				String addressText = address.getText().toString();
				System.out.println("address: "+addressText);
				dc.setAddress(addressText);
				if (dc.validateAddress()){
					System.out.println("Lat long: "+dc.getLatitude()+","+dc.getLongitude());
				} else {
					System.out.println("error");
				}
			}
		});
    }
}
